Skip to content

fix(api): keep the sub type of a question fixed after creation - #3975

Merged
Chartman123 merged 1 commit into
mainfrom
fix/lock-question-subtype
Nov 21, 2026
Merged

Chartman123 merged 1 commit into
mainfrom
fix/lock-question-subtype

Conversation

@AndyScherzinger

Copy link
Copy Markdown
Member

Problem

updateQuestion rejects a change of type, but a PATCH could still change, add or remove extraSettings.questionType. A grid question could switch from radio to number after it already had answers, and the stored answers then no longer matched the question.

Change

A PATCH whose extraSettings has a different questionType than the stored one is now rejected with the same 403 response as a type change. The check is generic, so it covers every question type, not only grids. The linear scale sub types planned in #3635 and #3637 rely on it.

The frontend is not affected: every extraSettings save spreads the stored settings, so it always sends the stored questionType back. The grid editor has no control to change it. Copying a question and cloning a form copy the stored settings on the server side.

docs/API_v3.md documents the new restriction. openapi.json does not change.

How to verify

  1. Create a grid question with subtype: radio.
  2. PATCH /api/v3/forms/{formId}/questions/{questionId} with {"keyValuePairs":{"extraSettings":{"questionType":"number"}}} returns 403. Sending {} also returns 403. Before this change, both returned 200.
  3. The same PATCH with "questionType":"radio" and other changes returns 200.
  4. In the editor, rename the grid question, change the range of a linear scale question and copy the grid question. All of these still save without errors.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (N/A)

updateQuestion rejects a change of `type`, but a PATCH could still
change, add or remove `extraSettings.questionType`. A grid question
could switch from radio to number after it already had answers, and
the stored answers no longer matched the question.

Reject an `extraSettings` update whose `questionType` differs from the
stored one, with the same 403 response the `type` check uses. The
check applies to every question type, so sub types added later are
covered as well. The web frontend always sends the stored extra
settings back, so normal editing is not affected.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Chartman123

Copy link
Copy Markdown
Collaborator

/backport to stable5.4

@backportbot backportbot Bot added the backport-request Pending backport by the backport-bot label Nov 21, 2026
@Chartman123
Chartman123 merged commit a0de70a into main Nov 21, 2026
52 checks passed
@Chartman123
Chartman123 deleted the fix/lock-question-subtype branch November 21, 2026 15:28
@backportbot backportbot Bot removed the backport-request Pending backport by the backport-bot label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants